package it.orma.iridehr.controllers;

import it.orma.iridehr.exceptions.DatiException;
import it.orma.iridehr.service.TipologicheService;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller

public class TipologieScuoleController {
	
	@Autowired
	private TipologicheService tipologicheService;
	
	@RequestMapping(value ="/superiori.json", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody List<String> scuoleSuperiori(){
		List<String> superiori;
		try {
			superiori = tipologicheService.listaScuole("/studi/superiori/superiore",true);
		} catch (DatiException e) {
			return new ArrayList<String>();
		}
		return superiori;
	}
	
	@RequestMapping(value ="/universita.json", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody List<String> universita(){
		List<String> universita;
		try {
			universita = tipologicheService.listaScuole("/studi/universitari/universita",true);
		} catch (DatiException e) {
			return new ArrayList<String>();
		}
		return universita;
	}
	
	@RequestMapping(value ="/masters.json", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody List<String> masters(){
		List<String> masters;
		try {
			masters = tipologicheService.listaScuole("/studi/masters/master",true);
		} catch (DatiException e) {
			return new ArrayList<String>();
		}
		return masters;
	}
	
	@RequestMapping(value ="/altri.json", method = RequestMethod.GET, produces = "application/json")
	public @ResponseBody List<String> altri(){
		List<String> altri;
		try {
			altri = tipologicheService.listaScuole("/studi/altri/altro",true);
		} catch (DatiException e) {
			return new ArrayList<String>();
		}
		return altri;
	}
}
